<?php
require_once('./admin.php');

$title = __('General Options');
$parent_file = 'options-general.php';

include(WPADMININC . 'admin-header.php');
 
$currentSlug = $wpdb->get_var("SELECT slug FROM $wpdb->blogs WHERE id = '$blogdata->id'");
?>
<script src="<?php echo SRCROOT ?>/wp-includes/js/prototype.js" type="text/javascript"></script>
<?php if ( isset($_SESSION['options_error']) ) : ?>
	<div class="error">
	<ul>
	<?php
	foreach($_SESSION['options_error'] as $error) echo "<li>$error</li>";
	?>
	</ul>
	</div>
<?php unset($_SESSION['options_error']); endif; ?> 
<div class="wrap">
<h2><?php _e('General Options') ?></h2>
<form method="post" action="options.php" id="optionform">
<?php wp_nonce_field('update-options') ?>
<table class="optiontable"> 
<tr valign="top"> 
<th scope="row"><?php _e('Blog title:') ?></th> 
<td><input name="blogname" type="text" id="blogname" value="<?php form_option('blogname'); ?>" size="35" /></td> 
</tr> 
<tr valign="top"> 
<th scope="row"><?php _e('Tagline:') ?></th> 
<td><input name="blogdescription" type="text" id="blogdescription" value="<?php form_option('blogdescription'); ?>" size="40" />
<br />
<?php _e('In a few words, explain what this blog is about.') ?></td> 
</tr> 
<tr valign="top"> 
<th scope="row"><?php _e('Slug:') ?></th>
<td><div id="slugMsg" style="float:right"></div><input name="slug" type="text" id="slug" value="<?php echo $currentSlug ?>" size="40" />
<br />
What will appear in your blog's url. If you make the slug <strong>myblog</strong>, your url will be http://<?php echo (SUBDOMAINS ? '' : MAINDOMAIN . '/' ) ?><strong>myblog</strong><?php echo (SUBDOMAINS ? '.'.MAINDOMAIN : '' ) ?>. A slug may contain numbers, lowercase letters, underscores, and hyphens.</td>
</tr>
<tr valign="top"> 
<th scope="row"><?php _e('E-mail address:') ?> </th>
<td><input name="admin_email" type="text" id="admin_email" value="<?php form_option('admin_email'); ?>" size="40" class="code" />
<br />
<?php _e('This address is used only for admin purposes.') ?></td> 
</tr>
<tr valign="top"> 
<th scope="row"><?php _e('Commenting:') ?></th> 
<td>
<?php
	$comment_registration = get_settings('comment_registration');
	$comment_priviliges = get_settings('comment_priviliges');
?>
	
<select name="commentpolicy">
	<option value="anonymous"><?php _e('Anyone may comment (recommended for most blogs)'); ?></option>
	<option value="registered" <?php echo  ($comment_registration && !$comment_priviliges) ? "selected='selected'" : " " ?>>
<?php printf(__('Only %s users may comment'), get_settings('site_title'));?> 
</option>
	<option value="priviliges" <?php echo  $comment_priviliges ? "selected='selected'" : " " ?> >
<?php printf(__('Only users who have permissions on %s may comment'), get_settings('blogname'));?>
</option>
</select>
</td>
</tr> 
</table> 
<fieldset class="options"> 
<legend><?php _e('Date and Time') ?></legend> 
<table class="optiontable"> 
<tr> 
<th scope="row"><?php _e('<abbr title="Coordinated Universal Time">UTC</abbr> time is:') ?> </th> 
<td><code><?php echo gmdate('Y-m-d g:i:s a'); ?></code></td> 
</tr>
<tr>
<th scope="row"><?php _e('Times in the blog should differ by:') ?> </th>
<td><input name="gmt_offset" type="text" id="gmt_offset" size="2" value="<?php form_option('gmt_offset'); ?>" /> 
<?php _e('hours') ?> </td>
</tr>
<tr>
<th scope="row"><?php _e('Local time zone abbreviation:') ?> </th>
<td><input name="time_zone" type="text" id="time_zone" size="2" value="<?php form_option('time_zone'); ?>" /><br/>
<?php _e('Helpful to differentiate between UTC and local times that are displayed') ?></td>
</tr>
<tr>
<th scope="row"><?php _e('Default date format:') ?></th>
<td><input name="date_format" type="text" id="date_format" size="30" value="<?php form_option('date_format'); ?>" /><br />
<?php _e('Output:') ?> <strong><?php echo mysql2date(get_settings('date_format'), current_time('mysql')); ?></strong></td>
</tr>
<tr>
<th scope="row"><?php _e('Default time format:') ?></th>
<td><input name="time_format" type="text" id="time_format" size="30" value="<?php form_option('time_format'); ?>" /><br />
<?php _e('Output:') ?> <strong><?php echo gmdate(get_settings('time_format'), current_time('timestamp')); ?></strong></td>
</tr> 
<tr>
<th scope="row">&nbsp;</th>
<td><?php _e('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Click "Update options" to update sample output.') ?> </td>
</tr>
<tr>
<th scope="row"><?php _e('Weeks in the calendar should start on:') ?></th>
<td><select name="start_of_week" id="start_of_week">
<?php
for ($day_index = 0; $day_index <= 6; $day_index++) :
if ($day_index == get_settings('start_of_week')) $selected = " selected='selected'";
else $selected = '';
echo "\n\t<option value='$day_index' $selected>$weekday[$day_index]</option>";
endfor;
?>
</select></td>
</tr>
</table>
</fieldset> 

<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update options &raquo;') ?> " />
<input type="hidden" name="options_general" value="true" /> 
<input type="hidden" name="action" value="update" /> 
<input type="hidden" name="page_options" value="blogname,blogdescription,admin_email,users_can_register,gmt_offset,time_zone,date_format,time_format,start_of_week,comment_registration,comment_priviliges,default_role" /> 
</p>
<?php echo tokeninput('options.php', 'update', "blogname,blogdescription,admin_email,users_can_register,gmt_offset,time_zone,date_format,time_format,start_of_week,comment_registration,comment_priviliges,default_role")?>
</form>

</div> 

<script type="text/javascript">
<!--

	function checkFeedback(msgName, elementID, params, timeout) {
		var msg = document.getElementById(msgName).innerHTML;
		var loginMsg = msg.substring(msg.indexOf('>')+1, msg.indexOf(':')-1);
		var inputValue = document.getElementById(elementID).value;
		if (loginMsg != inputValue)
		{
			new Ajax.Updater(msgName,'<?php echo SRCROOT ?>/ajax/availability.php', {
				asynchronous : true,
 				method : 'post',
					parameters : params + inputValue
				});
			setTimeout('checkFeedback("' + msgName + '","' + elementID + '","' + params + '",' + timeout*2 + ');',timeout);
		}
	};
	
	new Form.Element.Observer('slug', 0.5, 
		function(element, value) {
 			if(document.getElementById('slug').value.indexOf('&') > 0)
	 			document.getElementById('slugMsg').innerHTML ='<font color=\"red\">'+document.getElementById('slug').value+': Invalid slug<\/font>';
 			else
 			{
				new Ajax.Updater('slugMsg','<?php echo SRCROOT ?>/ajax/availability.php', {
					asynchronous : true,
		 			method : 'post',
	 				parameters : 'action=checkBlogname&currentSlug=<?php echo $currentSlug ?>&name=' + value
 				});
 				setTimeout('checkFeedback("slugMsg","slug","action=checkBlogname&currentSlug=<?php echo $currentSlug ?>&name=",1000);',500);
 			}
		}
	);
		
-->
</script>

<?php include(WPADMININC . 'admin-footer.php') ?>
